/*
 * @Descripttion: 
 * @version: 
 * @@Company: DCIT-SH
 * @Author: 王富银
 * @Date: 2024-08-08 19:22:45
 * @LastEditors: Sunny Chen
 * @LastEditTime: 2024-08-10 13:52:45
 */

import axios from "axios";

const api = axios.create({
  baseURL: import.meta.env.VITE_BASE_URL,
  timeout: 3000,
});
api.interceptors.request.use(
  (config) => {
    return config;
  },
  (err) => {
    Promise.reject(err);
  }
);
api.interceptors.response.use(
  (response) => {
    const data = response.data;
    console.log(response);
    if (response.status == 200 || response.status == 201) {
      return Promise.resolve(data);
    } else {
      return Promise.reject(data);
    }
  },
  (err) => {
    return Promise.reject(err);
  }
);

export default api;
